#pragma once
#include "DX9Engine.h"

// On Screen Display
// FOR DEBUG USE
class OSD
{
	DX9Engine*	pEngine;
	Input*		pInput;
	// variables for display
	int m_fps, m_currTime, m_prevTime, m_frameRate;
	float m_tbf;
public:
	OSD(){}
	~OSD(){}

	void initialize() 
	{
		pEngine=DX9Engine::getInstance();
		pInput=Input::getInstance();
	}
	void update(float dT)
	{
		// calculate fps
		m_currTime = clock();
		if(m_currTime - m_prevTime >= 1000)	{
			m_prevTime = m_currTime;
			m_fps = m_frameRate;
			m_frameRate = 0;
		} else {
			++m_frameRate;
		}
		m_tbf = dT;
	}
	void renderText()
	{
		char buff[500] = {0};
		RECT bounds;
		bounds = setBounds(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH);
		sprintf_s(buff, "dT %f\nfps %d\nx%4.0f\ny%4.0f", m_tbf, m_fps, pInput->getMousePos().x, pInput->getMousePos().y);
		pEngine->writeText(buff, bounds);
	}
	RECT setBounds(int top, int left, int bottom, int right)
	{
		RECT temp;
		temp.top = top;
		temp.left = left;
		temp.bottom = bottom;
		temp.right = right;
		return temp;
	}
};